const json = require('./basic/config');
// app.js
require('basic/api/wxlr.js'); //引入登录及接口请求中转
require('basic/wxextend/we.js'); // wx自定义小程序全局方法和全局变量
App({
	onLaunch() {
		// this.getCommData();
		// 获取系统状态栏信息
		wx.getSystemInfo({
			success: e => { 
				this.globalData.StatusBar = e.statusBarHeight;
				let capsule = wx.getMenuButtonBoundingClientRect();
				if (capsule) {
					this.globalData.Custom = capsule;
					this.globalData.CustomBar = capsule.bottom + capsule.top - e.statusBarHeight;
				} else {
					this.globalData.CustomBar = e.statusBarHeight + 50;
				}
			}
		})
	},
	getCommData: function(){
		var _this = this;
		//获取公共新闻分组
		wx.$requestApi("sys/Wxoperation/newsget", {}, function(res){
			if(res.code == 0){
				var apiNewsObj = {};
				var aResult = res.data;
				for(var i=0;i<aResult.length;i++){
					var nObj = {}
					for(let key in aResult[i]){
						if(key != 'iID' && key != 'iDel' && key != 'iDis' && key != 'iTime'){
							nObj[key] = aResult[i][key];
						}
						if(key == 'sTabPost' || key == 'sListPost' || key == 'sThumbsUpApi' || key == 'sOperation'){
							nObj[key] = aResult[i][key] != '' ? aResult[i][key].split(",") : [];
						}
					}
					apiNewsObj[aResult[i]['sGroup']] = nObj;
				}
				_this.globalData.api_common_news = apiNewsObj;
				console.log(apiNewsObj);
			}
		})
	},
	globalData: {
		"page_home": json.page_home, //默认首页
		"link_image": json.link.image,
		"link_upload": json.link.upload,
		"link_upload_r": json.link.upload_r,
		"link_upload_e": json.link.upload_e,
		// "api_common_news": json.news
	}
})